 
function setUpTextboxes(selectElement,textElement)
{
	var text = document.getElementById(textElement);
	var gpa = document.getElementById("gpa");
	var gradingscale = document.getElementById("gradingScale");
        
	enableText(gpa);
	enableText(gradingscale);
    if(text.name == "otherType")
	{
		if(selectElement.value == "other")
		{
			text.disabled = false;
			text.style.backgroundColor = "white";
		}
		else disableText(text);
	}
	else	
	{
		if(selectElement.value == "other")
		{
			text.disabled = false;
			text.style.backgroundColor = "white";
		}
		else {disableText(text);}
	}
	
	if(document.getElementById('degreeType').value == "PhD")
	{
		disableText(gpa);
		disableText(gradingscale);
	}

       
}
function setUpMSProgram(selectElement, textElement)
{
    var text = document.getElementById(textElement);
    if(selectElement.value == "campus")
    {
        enableText(text);
    }
    else  if(selectElement.value == "DE")
    {
        disableText(text);
    }
        
}


function selectOtherSource(selectElement, textElement)
{
	var source = document.getElementById(textElement);
	disableText(source);
	if(source.name == "website")
	{
		if(selectElement.value == "MUM Website")
		{	
			source.disabled  = false;
			source.style.backgroundColor = "white";
		}
		else
		{
			disableText(source);
		}
	}
	else if(source.name == "otherSource")
	{
		if(selectElement.value == "other")
		{
			source.disabled = false;
			source.style.backgroundColor = "white";
		}
		else
		{
			disableText(source);
		}
	}
}
function disableText(textElement)
{
	textElement.disabled = true;
	textElement.style.background = "#e0e0e0";
	textElement.value = "";
}
function enableText(textElement)
{
	textElement.disabled = false;
	textElement.style.backgroundColor = "white";
}
function selectExp(checkElement, id)
{
	if(checkElement.checked)
	{
		var noExp = id+"NoExp";
		var noExpBox = document.getElementById(noExp);
		noExpBox.checked = false;
	}
}

function selectNoExp(checkElement, id)
{
	if(checkElement.checked)
	{
		if (document.getElementById("StacksNoExp").checked==true)
		{
			document.getElementById("StacksSelfStudy").checked=false;
			document.getElementById("StacksWork").checked=false;
			document.getElementById("StacksAcademic").checked=false;
		}
		
		if (document.getElementById("QueuesNoExp").checked==true)
		{
			document.getElementById("QueuesSelfStudy").checked=false;
			document.getElementById("QueuesWork").checked=false;
			document.getElementById("QueuesAcademic").checked=false;
		}
		
		if (document.getElementById("LinkedListsNoExp").checked==true)
		{
			document.getElementById("LinkedListsSelfStudy").checked=false;
			document.getElementById("LinkedListsWork").checked=false;
			document.getElementById("LinkedListsAcademic").checked=false;
		}
		
		
		
		//var selfExp = id+" SelfStudy";
		//var selfBox = document.getElementById(selfExp);
		//selfBox.checked = false;

		//var workExp = id+" Work";
		//var workBox = document.getElementById(workExp);
		//workBox.checked = false;

		//var acdmExp = id+" Academic";
		//var acdmBox = document.getElementById(acdmExp);
		//acdmBox.checked = false;		
	}
}

function showBlock(checkElement, blockId)
{
	var block = document.getElementById(blockId);
	if(checkElement.checked)
	{
		block.style.display = "inline";
		block.style.visibility = "visible";
	}
	else
		block.style.visibility = "hidden";
}


/*	These variables are for the addExp and removeExp functions to keep track of
	how many professional, academic or selfstudy experiences are on screen
*/
var InstAdd = 0;
var InstRem = 0;
var InstCount = 0;
var ProfAdd = 0;
var ProfRem = 0;
var ProfCount = 0;
var AcdmAdd = 0;
var AcdmRem = 0;
var AcdmCount = 0;
var SelfAdd = 0;
var SelfRem = 0;
var SelfCount = 0;
var error="FORM INCOMPLETE OR INCORRECT:\n\n";

function getAddNum(type)
{
	if(type == "Institute")
		return InstAdd;
	if(type == "ProfExp")
		return ProfAdd;
	if(type == "AcdmExp")
		return AcdmAdd;
	if(type == "SelfExp")
		return SelfAdd;
}
function getCountNum(type)
{
	if(type == "Institute")
		return InstCount;
	if(type == "ProfExp")
		return ProfCount;
	if(type == "AcdmExp")
		return AcdmCount;
	if(type == "SelfExp")
		return SelfCount;
}
function addFromInput(type) /* type holds a string */
{
	//where we append
	var section = document.getElementById(type);

	// what we append visually
	var newBlk = document.createElement("div");
	newBlk.setAttribute("id",type+getAddNum(type));

	// hidden variable to store the value for the form
	var newHvr = document.createElement("input");
	newHvr.setAttribute("type","hidden");
	newHvr.setAttribute("name",type+getAddNum(type));
	
	
	// create button so that they can remove it	
	var remBtn = document.createElement("button");
	remBtn.setAttribute("type","button");
	remBtn.appendChild(document.createTextNode("Remove"));

	var num = getAddNum(type); /* var that won't change for dynamic function */
	remBtn.onclick = function(){removeData(type, num)};

	var btnDiv = document.createElement("div");
	btnDiv.style.textAlign = "right";
	btnDiv.appendChild(remBtn);		
	
	// So we can apply style to the headers inside the section
	var spanT = document.createElement("span");
	spanT.className="b";

	if(type == "Institute")
	{
		/* set variable */
		InstAdd++;
		InstCount++;
		document.getElementById('instCount').value = InstCount;
		
		/* collect onscreen data and clear input fields */
		var name = document.getElementById('instName').value;
		document.getElementById('instName').value = "";
		document.getElementById('instName').style.backgroundColor = "white";

		var loc = document.getElementById('instLocation').value;
		document.getElementById('instLocation').value = "";
		document.getElementById('instLocation').style.backgroundColor = "white";

		var dates = document.getElementById('instDates').value;
		document.getElementById('instDates').value = "";
		document.getElementById('instDates').style.backgroundColor = "white";

		var degree = document.getElementById('instDegree').value;
		document.getElementById('instDegree').value = "";
		document.getElementById('instDegree').style.backgroundColor = "white";

		var subject = document.getElementById('instSubject').value;
		document.getElementById('instSubject').value = "";
		document.getElementById('instSubject').style.backgroundColor = "white";
		
		var gpa = document.getElementById('instGPA').value;
		document.getElementById('instGPA').value = "";
		document.getElementById('instGPA').style.backgroundColor = "white";

				
		/* set the hidden variable */
		newHvr.value += "Institute Name:               "+name+"\n";
		newHvr.value += "Location:                     "+loc+"\n";
		newHvr.value += "Dates:                        "+dates+"\n";
		newHvr.value += "Degree:                       "+degree+"\n";
		newHvr.value += "Subject:                      "+subject+"\n";
		newHvr.value += "GPA:                          "+gpa+"\n";
		
	    
		/* create and set hidden var for each field Educational History */
		var instName = document.createElement("input");
		instName.setAttribute("type", "hidden");
		instName.setAttribute("name", "instname"+getAddNum(type));
		instName.value += name;
		var instLocation = document.createElement("input");
		instLocation.setAttribute("type", "hidden");
		instLocation.setAttribute("name", "instlocation"+getAddNum(type));
		instLocation.value += loc;
		var instDates = document.createElement("input");
		instDates.setAttribute("type", "hidden");
		instDates.setAttribute("name", "instdates"+getAddNum(type));
		instDates.value = dates;
		var instSubject = document.createElement("input");
		instSubject.setAttribute("type", "hidden");
		instSubject.setAttribute("name", "instsubject"+getAddNum(type));
		instSubject.value = subject;
		var instDegree = document.createElement("input");
		instDegree.setAttribute("type", "hidden");
		instDegree.setAttribute("name", "instdegree"+getAddNum(type));
		instDegree.value = degree;
		var instGPA = document.createElement("input");
		instGPA.setAttribute("type", "hidden");
		instGPA.setAttribute("name", "instgpa"+getAddNum(type));
		instGPA.value += gpa;

		/* populate the newBlk node */
		newBlk.appendChild(newHvr);
		newBlk.appendChild(instName);
		newBlk.appendChild(instLocation);
		newBlk.appendChild(instDates);
		newBlk.appendChild(instSubject);
		newBlk.appendChild(instGPA);
		newBlk.appendChild(instDegree);
		
		var span1 = spanT.cloneNode(false);
		span1.appendChild(document.createTextNode("Institute: "));
		span1.style.width = "100px";
		newBlk.appendChild(span1);
		newBlk.appendChild(document.createTextNode(name));
		newBlk.appendChild(document.createElement("br"));
		
		var span2 = spanT.cloneNode(false);	
		span2.appendChild(document.createTextNode("Location: "));
		span2.style.width = "100px";
		newBlk.appendChild(span2);
		newBlk.appendChild(document.createTextNode(loc));		
		newBlk.appendChild(document.createElement("br"));
		
		var span3 = spanT.cloneNode(false);	
		span3.appendChild(document.createTextNode("Dates: "));
		span3.style.width = "100px";
		newBlk.appendChild(span3);
		newBlk.appendChild(document.createTextNode(dates));
		newBlk.appendChild(document.createElement("br"));

		var span4 = spanT.cloneNode(false);	
		span4.appendChild(document.createTextNode("Degree: "));		
		span4.style.width = "100px";
		newBlk.appendChild(span4);
		newBlk.appendChild(document.createTextNode(degree));
		newBlk.appendChild(document.createElement("br"));
	
		
		var span5 = spanT.cloneNode(false);	
		span5.appendChild(document.createTextNode("Subject: "));		
		span5.style.width = "100px";
		newBlk.appendChild(span5);
		newBlk.appendChild(document.createTextNode(subject));
		newBlk.appendChild(document.createElement("br"));

		var span6 = spanT.cloneNode(false);	
		span6.appendChild(document.createTextNode("GPA: "));		
		span6.style.width = "100px";
		newBlk.appendChild(span6);
		newBlk.appendChild(document.createTextNode(gpa));
		newBlk.appendChild(document.createElement("br"));

		newBlk.appendChild(btnDiv);		
		newBlk.appendChild(document.createElement("hr"));
		
	}else if(type == "AcdmExp")
	{
		/* set variable */
		AcdmAdd++;
		AcdmCount++;

		document.getElementById('acdmExpCount').value = AcdmCount;

		// hidden vars for acdmExp 
		var acdmLang = document.createElement("input");						
		acdmLang.setAttribute("type", "hidden");
		acdmLang.setAttribute("name", "acdmlanguage"+getAddNum(type));	
		var acdmCourse = document.createElement("input");						
		acdmCourse.setAttribute("type", "hidden");
		acdmCourse.setAttribute("name", "acdmcourse"+getAddNum(type));	
		var acdmYears = document.createElement("input");						
		acdmYears.setAttribute("type", "hidden");
		acdmYears.setAttribute("name", "acdmyears"+getAddNum(type));	
		var acdmDescr = document.createElement("input");
		acdmDescr.setAttribute("type", "hidden");
		acdmDescr.setAttribute("name", "acdmdescr"+getAddNum(type));
		
		/* collect onscreen data and clear input fields*/
		var lang;
		if(document.getElementById('acdmLang').value == 'other')
		{
			var acdmOther = document.getElementById('acdmOther')
			lang = acdmOther.value;
			acdmOther.value = "";
			acdmOther.disabled = true;
			acdmOther.style.backgroundColor = "#e0e0e0";  
		}
		else
		{
			lang = document.getElementById('acdmLang').value;
		}
		document.getElementById('acdmLang').value = "none";
		
		var course = document.getElementById('course').value;
		document.getElementById('course').value = "";
		
		var years = document.getElementById('acdmYears').value;
		document.getElementById('acdmYears').value = "";
		
		var descr = document.getElementById('acdmDescr').value;
		document.getElementById('acdmDescr').value = "";

		/* set the hidden variable */
		newHvr.value += "Language:                     "+lang+"\n";
		newHvr.value += "Year(s):                      "+years+"\n";
		newHvr.value += "Course Title:                 "+course+"\n";
		newHvr.value += "Description:                  "+descr+"\n";
		
		acdmLang.value = lang;
		acdmCourse.value = course;
		acdmYears.value = years;
		acdmDescr.value = descr;
		
		/* populate the newBlk node */
		newBlk.appendChild(newHvr);
		newBlk.appendChild(acdmLang);
		newBlk.appendChild(acdmCourse);
		newBlk.appendChild(acdmYears);
		newBlk.appendChild(acdmDescr);
		
		var span1 = spanT.cloneNode(false);
		span1.appendChild(document.createTextNode("Language: "));
		newBlk.appendChild(span1);
		newBlk.appendChild(document.createTextNode(lang+"     "));

		var span2 = spanT.cloneNode(false);	
		span2.appendChild(document.createTextNode("Year(s): "));		
		newBlk.appendChild(span2);
		newBlk.appendChild(document.createTextNode(years));
		
		newBlk.appendChild(document.createElement("br"));
		
		var span3 = spanT.cloneNode(false);	
		span3.appendChild(document.createTextNode("Course Title: "));		
		newBlk.appendChild(span3);
		newBlk.appendChild(document.createTextNode(course));
		
		newBlk.appendChild(document.createElement("br"));
		
		var span4 = spanT.cloneNode(false);	
		span4.appendChild(document.createTextNode("Description: "));		
		newBlk.appendChild(span4);
		newBlk.appendChild(document.createTextNode(descr));

		newBlk.appendChild(btnDiv);
		newBlk.appendChild(document.createElement("hr"));
	}
	else if(type == "ProfExp")
	{
		/* set variable */
		ProfAdd++;
		ProfCount++;
		document.getElementById('profExpCount').value = ProfCount;
		
		// hidden vars for profExp 
		var profDur = document.createElement("input");
		profDur.setAttribute("type", "hidden");
		profDur.setAttribute("name", "profduration"+getAddNum(type));	
		var profLang = document.createElement("input");						
		profLang.setAttribute("type", "hidden");
		profLang.setAttribute("name", "proflanguage"+getAddNum(type));	
		var profEmployer = document.createElement("input");						
		profEmployer.setAttribute("type", "hidden");
		profEmployer.setAttribute("name", "profemployer"+getAddNum(type));	
		var profYears = document.createElement("input");						
		profYears.setAttribute("type", "hidden");
		profYears.setAttribute("name", "profyears"+getAddNum(type));	
		var profDescr = document.createElement("input");
		profDescr.setAttribute("type", "hidden");
		profDescr.setAttribute("name", "profdescr"+getAddNum(type));
		
		/* collect onscreen data and clear input fields*/
		var lang;
		if(document.getElementById('ProfLang').value == 'other')
		{
			var profOther = document.getElementById('ProfOther')
			lang = profOther.value;
			profOther.value = "";
			profOther.disabled = true;
			profOther.style.backgroundColor = "#e0e0e0";  
		}
		else
		{
			lang = document.getElementById('ProfLang').value;
		}
		document.getElementById('ProfLang').value = "none";
		
		var employer = document.getElementById('ProfEmployer').value;
		document.getElementById('ProfEmployer').value = "";
		
		var duration = document.getElementById('ProfDuration').value;
		document.getElementById('ProfDuration').value = "0";
		
		var years = document.getElementById('ProfYears').value;
		document.getElementById('ProfYears').value = "";
		
		var descr = document.getElementById('ProfDescr').value;
		document.getElementById('ProfDescr').value = "";
		
		/* set the hidden variables */
		newHvr.value += "Language:                     "+lang+"\n";
		newHvr.value += "Employer:                     "+employer+"\n";
		newHvr.value += "Duration:                     "+duration+" years\n";
		newHvr.value += "Year(s):                      "+years+"\n";
		newHvr.value += "Description:                  "+descr+"\n";
		
		profDur.value = duration;
		profLang.value = lang;
		profEmployer.value = employer;
		profYears.value = years;
		profDescr.value = descr;
		
		/* populate the newBlk node */
		newBlk.appendChild(newHvr);
		newBlk.appendChild(profDur);
		newBlk.appendChild(profLang);
		newBlk.appendChild(profEmployer);
		newBlk.appendChild(profYears);
		newBlk.appendChild(profDescr);
		
		var span1 = spanT.cloneNode(false);
		span1.appendChild(document.createTextNode("Language: "));
		newBlk.appendChild(span1);
		newBlk.appendChild(document.createTextNode(lang+"     "));
		
		var span2 = spanT.cloneNode(false);	
		span2.appendChild(document.createTextNode("Employer: "));
		newBlk.appendChild(span2);
		newBlk.appendChild(document.createTextNode(employer));
		
		newBlk.appendChild(document.createElement("br"));
		
		var span3 = spanT.cloneNode(false);	
		span3.appendChild(document.createTextNode("Duration: "));
		newBlk.appendChild(span3);
		newBlk.appendChild(document.createTextNode(duration+"     "));

		var span4 = spanT.cloneNode(false);	
		span4.appendChild(document.createTextNode("Year(s): "));		
		newBlk.appendChild(span4);
		newBlk.appendChild(document.createTextNode(years));
	
		newBlk.appendChild(document.createElement("br"));
		
		var span5 = spanT.cloneNode(false);	
		span5.appendChild(document.createTextNode("Description: "));		
		newBlk.appendChild(span5);
		newBlk.appendChild(document.createTextNode(descr));

		newBlk.appendChild(btnDiv);		
		newBlk.appendChild(document.createElement("hr"));
	}
	else if(type == "SelfExp")
	{
		/* set variable */
		SelfAdd++;
		SelfCount++;
		document.getElementById('selfExpCount').value = SelfCount;

		// hidden vars for acdmExp 
		var selfLang = document.createElement("input");						
		selfLang.setAttribute("type", "hidden");
		selfLang.setAttribute("name", "selflanguage"+getAddNum(type));	
		var selfResource = document.createElement("input");						
		selfResource.setAttribute("type", "hidden");
		selfResource.setAttribute("name", "selfresource"+getAddNum(type));	
		var selfYears = document.createElement("input");						
		selfYears.setAttribute("type", "hidden");
		selfYears.setAttribute("name", "selfyears"+getAddNum(type));	
		var selfHours = document.createElement("input");
		selfHours.setAttribute("type", "hidden");
		selfHours.setAttribute("name", "selfhours"+getAddNum(type));
		var selfWeeks = document.createElement("input");
		selfWeeks.setAttribute("type", "hidden");
		selfWeeks.setAttribute("name", "selfweeks"+getAddNum(type));
		var selfDescr = document.createElement("input");
		selfDescr.setAttribute("type", "hidden");
		selfDescr.setAttribute("name", "selfdescr"+getAddNum(type));

		/* collect onscreen data and clear input fields*/
		var lang;
		if(document.getElementById('SelfLang').value == 'other')
		{
			var selfOther = document.getElementById('SelfOther')
			lang = selfOther.value;
			selfOther.value = "";
			selfOther.disabled = true;
			selfOther.style.backgroundColor = "#e0e0e0";  
		}
		else
		{
			lang = document.getElementById('SelfLang').value;
		}
		document.getElementById('SelfLang').value = "none";
		
		var resource = document.getElementById('SelfResource').value;
		document.getElementById('SelfResource').value = "";
		
		var weeks = document.getElementById('SelfWeeks').value;
		document.getElementById('SelfWeeks').value = "";
		
		var hours = document.getElementById('SelfHours').value;
		document.getElementById('SelfHours').value = "";
		
		var years = document.getElementById('SelfYears').value;
		document.getElementById('SelfYears').value = "";
		
		var descr = document.getElementById('SelfDescr').value;
		document.getElementById('SelfDescr').value = "";

		/* set the hidden variable */
		newHvr.value += "Language:                     "+lang+"\n";
		newHvr.value += "Weeks:                        "+weeks+"\n";
		newHvr.value += "Hours/Week:                   "+hours+"\n";
		newHvr.value += "Year(s):                      "+years+"\n";
		newHvr.value += "Resource:                     "+resource+"\n";
		newHvr.value += "Description:                  "+descr+"\n";
		
		selfLang.value = lang;
		selfResource.value = resource;
		selfYears.value = years;
		selfWeeks.value = weeks;
		selfHours.value = hours;
		selfDescr.value = descr;
		/* populate the newBlk node */
		newBlk.appendChild(newHvr);
		newBlk.appendChild(selfLang);
		newBlk.appendChild(selfResource);
		newBlk.appendChild(selfYears);
		newBlk.appendChild(selfWeeks);
		newBlk.appendChild(selfHours);
		newBlk.appendChild(selfDescr);

		var span1 = spanT.cloneNode(false);
		span1.appendChild(document.createTextNode("Language: "));
		newBlk.appendChild(span1);
		newBlk.appendChild(document.createTextNode(lang+"     "));

		var span2 = spanT.cloneNode(false);
		span2.appendChild(document.createTextNode("Weeks: "));
		newBlk.appendChild(span2);		
		newBlk.appendChild(document.createTextNode(weeks+"     "));

		var span3 = spanT.cloneNode(false);
		span3.appendChild(document.createTextNode("Hours/Week: "));
		newBlk.appendChild(span3);
		newBlk.appendChild(document.createTextNode(hours+"     "));

		
		var span4 = spanT.cloneNode(false);
		span4.appendChild(document.createTextNode("Year(s): "));
		newBlk.appendChild(span4);		
		newBlk.appendChild(document.createTextNode(years));
		
		newBlk.appendChild(document.createElement("br"));

		var span5 = spanT.cloneNode(false);
		span5.appendChild(document.createTextNode("Resource: "));
		newBlk.appendChild(span5);		
		newBlk.appendChild(document.createTextNode(resource));
		
		newBlk.appendChild(document.createElement("br"));

		var span6 = spanT.cloneNode(false);
		span6.appendChild(document.createTextNode("Description: "));
		newBlk.appendChild(span6);		
		newBlk.appendChild(document.createTextNode(descr));
		
		newBlk.appendChild(btnDiv);
		newBlk.appendChild(document.createElement("hr"));
	}
	/* make sure we're being displayed */
	section.appendChild(newBlk);				
	section.style.display = "block";

		
}

function removeData(type, num)
{
	var section = document.getElementById(type);
	var blkNode = document.getElementById(type+num);
	section.removeChild(blkNode);	

	if(type == 'Institute')
	{
		InstRem++;
		InstCount--;
		document.getElementById('instCount').value = InstCount;
		if(InstAdd == InstRem)
			section.style.display = "none";
	}	
	else if(type == 'ProfExp')
	{
		ProfRem++;
		ProfCount--;
		document.getElementById('profExpCount').value = ProfCount;
		if(ProfAdd == ProfRem)
			section.style.display = "none";	
	}
	else if(type == 'AcdmExp')
	{
		AcdmRem++;
		AcdmCount--;
		document.getElementById('acdmExpCount').value = AcdmCount;
		if(AcdmAdd == AcdmRem)
			section.style.display = "none";	
	}
	else if(type == 'SelfExp')
	{
		SelfRem++;
		SelfCount--;
		document.getElementById('selfExpCount').value = SelfCount;
		if(SelfAdd == SelfRem)
			section.style.display = "none";	
	}
}